/**
 * 懒加载
 * 按需引入
 */

// 用到的ant组件
import {
  ConfigProvider,
  Layout,
  Input,
  InputNumber,
  Button,
  Switch,
  Checkbox,
  Select,
  Form,
  Row,
  Col,
  Modal,
  Table,
  Tabs,
  Dropdown,
  Spin,
  Menu,
  DatePicker,
  TimePicker,
  Upload,
  PageHeader,
  message,
  notification,
  Steps,
  Divider,
  Drawer,
  Collapse,
  Carousel,
  Cascader,
  Popover,
  List,
  Skeleton,
  Timeline,
  Tooltip,
  Space,
  Empty,
  Radio,
  Card,
  Avatar,
  Image,
  Tag,
  Tree,
  Popconfirm,
  Badge
} from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'

// ext library
import dayjs from 'dayjs'
import MComponent from 'microvideo-component'
import mapIconConfig from '@/views/business-component/modules/map/lib/map-icon-config'
import MvMap from 'microvideo-map'
import Icons from '@/icons' // 自定义icon组件
import LsdLayout from '@/components/layout'
import { get, isEqual } from '@/utils'
import Mitt from 'mitt'
import { getAllDict } from './dictionaries'
import { getText } from '../views/management/config/text.config'

export default {
  install: async app => {
    app.use(ConfigProvider)
    app.use(Layout)
    app.use(Input)
    app.use(InputNumber)
    app.use(Button)
    app.use(Switch)
    app.use(Checkbox)
    app.use(Select)
    app.use(Form)
    app.use(Row)
    app.use(Col)
    app.use(Modal)
    app.use(Table)
    app.use(Tabs)
    app.use(Dropdown)
    app.use(Spin)
    app.use(Menu)
    app.use(DatePicker)
    app.use(TimePicker)
    app.use(Upload)
    app.use(PageHeader)
    app.use(Steps)
    app.use(Divider)
    app.use(Drawer)
    app.use(Collapse)
    app.use(Carousel)
    app.use(Cascader)
    app.use(Popover)
    app.use(List)
    app.use(Skeleton)
    app.use(Timeline)
    app.use(Tooltip)
    app.use(Space)
    app.use(Empty)
    app.use(Radio)
    app.use(Card)
    app.use(Avatar)
    app.use(Image)
    app.use(Tag)
    app.use(Tree)
    app.use(Popconfirm)
    app.use(Badge)

    app.config.globalProperties.$confirm = Modal.confirm
    app.config.globalProperties.$message = message
    app.config.globalProperties.$notification = notification
    app.config.globalProperties.$info = Modal.info
    app.config.globalProperties.$success = Modal.success
    app.config.globalProperties.$error = Modal.error
    app.config.globalProperties.$warning = Modal.warning
    app.config.globalProperties.$get = get
    app.config.globalProperties.$isEqual = isEqual
    app.config.globalProperties.$bus = new Mitt()

    // 全局挂载组件/库

    app.use(MComponent).use(MvMap, {
      initMapConfig: {
        // v: '1.4.4',
        // 朱琦的高德账号
        // key: '496aacf98b85bf5bf1e140f729e7ed04',
        // securityJsCode: '7c12916c632cff4d24f8a7392807a7fa'
      },
      mapIconConfig
    })
    app.use(Icons)

    app.use(LsdLayout)

    // vue3 给原型上挂载属性
    app.config.globalProperties.$dayjs = dayjs

    // 大屏管理 全局挂载方法
    app.config.globalProperties.$getText = getText

    await getAllDict()
  }
}
